import {createAsyncThunk, createSlice} from "@reduxjs/toolkit";
import {getInterviewTitles} from "../../api/interview";

export const getInterviewTitleAsync = createAsyncThunk(
    'interview/getInterviewTitleAsync',
    async (payload, thunkAPI) => {
        const response = await getInterviewTitles()
        thunkAPI.dispatch(getInterviewTitleList(response.data.data))
    }
)

const interviewStore = createSlice({
    name: 'interview',
    initialState: {
        interviewTitleList: []
    },
    reducers: {
        getInterviewTitleList: (state, action) => {
            state.interviewTitleList = action.payload
        }
    }
})

export const {getInterviewTitleList} = interviewStore.actions
export default interviewStore.reducer